package com.yxs.yapp;

import android.app.Activity;
import android.os.Bundle;
import com.yxs.yapp.utils.YView;
import com.yxs.yapp.utils.YIntent;
import com.yxs.yapp.utils.Ysys;
import com.yxs.yapp.utils.Ynet;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.ImageView;
import android.media.MediaPlayer;
import android.widget.ProgressBar;

public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TextView About = findViewById(R.id.title);
        Button btnYEB = findViewById(R.id.yeb);
        Button btnYXS = findViewById(R.id.yxs);
        Button btnExit = findViewById(R.id.exit);      
        final MediaPlayer mdP = MediaPlayer.create(this, R.raw.m); // 从res/raw加载音频

        btnYEB.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 打开浏览器并跳转到指定链接
                YIntent.openWebPage(MainActivity.this,"http://yeb.7749.org");
            }
        });
        btnYXS.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ImageView iw = findViewById(R.id.imageView);
                ProgressBar pbv = findViewById(R.id.pb);
                YView.ShortToast(MainActivity.this,"Hello!");
                YView.toggleVisibility(iw);
                YView.toggleVisibility(pbv);
                mdP.start();
            }
        });   
        About.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 从当前Activity跳转到目标Activity
                YView.ShortToast(MainActivity.this, "Hi!");
            }
        });
        btnExit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                YView.ShortToast(MainActivity.this, "exiting");
                Ysys.ExitApp(MainActivity.this);
                
            }
        });
    }
}
